/*
package net.xdclass.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.retry.MessageRecoverer;
import org.springframework.amqp.rabbit.retry.RepublishMessageRecoverer;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

@Configuration
public class RabbitMQDLXConfig {

    // 主业务交换机
    public static final String EVENT_EXCHANGE = "short_link.event.exchange";

    // 正常业务队列
    public static final String ADD_LINK_QUEUE = "short_link.add.link.queue";
    public static final String ADD_LINK_ROUTING_KEY = "short_link.add.link.routing.key";

    // 死信交换机 + 死信队列
    public static final String DLX_EXCHANGE = "short_link.dlx.exchange";
    public static final String DLX_QUEUE = "short_link.dlx.queue";
    public static final String DLX_ROUTING_KEY = "short_link.dlx.routing.key";

    */
/*//*
/ 1. 事件交换机
    @Bean
    public TopicExchange eventExchange() {
        return new TopicExchange(EVENT_EXCHANGE, true, false);
    }

    // 2. 正常业务队列（绑定死信交换机）
    @Bean
    public Queue addLinkQueue() {
        Map<String, Object> args = new HashMap<>();
        args.put("x-dead-letter-exchange", DLX_EXCHANGE);
        args.put("x-dead-letter-routing-key", DLX_ROUTING_KEY);
        return new Queue(ADD_LINK_QUEUE, true, false, false, args);
    }

    // 3. 绑定业务队列和交换机
    @Bean
    public Binding addLinkBinding() {
        return BindingBuilder.bind(addLinkQueue()).to(eventExchange()).with(ADD_LINK_ROUTING_KEY);
    }*//*


    // 4. 死信交换机
    @Bean
    public TopicExchange dlxExchange() {
        return new TopicExchange(DLX_EXCHANGE, true, false);
    }

    // 5. 死信队列
    @Bean
    public Queue dlxQueue() {
        return new Queue(DLX_QUEUE, true);
    }

    // 6. 绑定死信队列和死信交换机
    @Bean
    public Binding dlxBinding() {
        return BindingBuilder.bind(dlxQueue()).to(dlxExchange()).with(DLX_ROUTING_KEY);
    }

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Bean
    public MessageRecoverer messageRecoverer() {
    	return new RepublishMessageRecoverer(rabbitTemplate, DLX_EXCHANGE, DLX_ROUTING_KEY);
    }
}
*/
